﻿/*----------------------------------------------------------------
  //Copyright (C) 2012 赵国伟
  //文件名：UrlsManage.cs
  //文件功能描述：url管理
  //创建人：赵国伟
  //生成时间：2012/03/17 16:15:00
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Shopping.Common;
using Shopping.Model;
using Shopping.DAL;

namespace Shopping.BLL
{
    public class URLManage
    {
        #region "返回商品最终页的Url访问地址；"
        /// <summary>
        /// 返回商品最终页的Url访问地址；
        /// </summary>
        /// <param name="goodsId"></param>
        /// <returns></returns>
        public string GetGoodsInfoUrl(int goodsId)
        {
            if (Config.IsRewrite)
                return string.Format("/Goods/{0}.html", goodsId);
            return string.Format("{0}?GoodsID={1}",Config.GoodsShowUrl, goodsId);
        }
        #endregion

        #region "返回频道页面Url访问地址；"
        /// <summary>
        /// 返回频道页面Url访问地址；
        /// </summary>
        /// <param name="fCategoryID"></param>
        /// <returns></returns>
        public string GetGoodsListUrl(int fCategoryID)
        {
            if (Config.IsRewrite)
                return string.Format("/List/{0}.html", fCategoryID);
            return string.Format("{0}?FCategoryID={1}", Config.GoodsChannelUrl, fCategoryID);
        }
        #endregion


        #region "生成二级列表页的地址；"
        /// <summary>
        /// 生成二级列表页的地址；
        /// </summary>
        /// <param name="fCategoryID"></param>
        /// <param name="sCategroyID"></param>
        /// <returns></returns>
        public string GetGoodsListUrl(int fCategoryID, int sCategroyID)
        {
            if (Config.IsRewrite)
                return string.Format("/List/{0}-{1}-0.html", fCategoryID, sCategroyID);
            return string.Format("{0}?FCategoryID={1}&SCategoryID={2}", Config.GoodsListUrl, fCategoryID, sCategroyID);
        }
        #endregion

        #region "生成三级列表页的地址；"
        /// <summary>
        /// 生成三级列表页的地址；
        /// </summary>
        /// <param name="fCategoryID"></param>
        /// <param name="sCategoryID"></param>
        /// <param name="tCategoryID"></param>
        /// <returns></returns>
        public string GetGoodsListUrl(int fCategoryID, int sCategoryID, int tCategoryID)
        {
            if (Config.IsRewrite)
                return string.Format("/List/{0}-{1}-{2}.html", fCategoryID, sCategoryID, tCategoryID);
            return string.Format("{0}?FCategoryID={1}&SCategoryID={2}&TCategoryID={3}", Config.GoodsListUrl, fCategoryID, sCategoryID, tCategoryID);
        }
        #endregion

        #region "根据查询对象；生成商城列表页Url;"
        /// <summary>
        /// 根据查询对象；生成商城列表页Url;
        /// </summary>
        /// <param name="q"></param>
        /// <returns></returns>
        public string GetGoodsListUrl(QueryGoodsAsPage q)
        {
            if (Config.IsRewrite)
                return string.Format("/List/{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}.html",
                    q.FCategoryID,
                    q.SCategoryID,
                    q.TCategoryID,
                    q.GoodsPlaceID,
                    q.BrandID,
                    q.PackUnitID,
                    q.GoodsPriceCondID,
                    q.Sorts,
                    q.CurPage);
            return string.Format("{0}?FCategoryID={1}&SCategoryID={2}&TCategoryID={3}&GoodsPlaceID={4}&BrandID={5}&PackUnitID={6}&GoodsPriceCondID={7}&Sorts={8}&CurPage={9}",
                Config.GoodsListUrl,
                q.FCategoryID,
                    q.SCategoryID,
                    q.TCategoryID,
                    q.GoodsPlaceID,
                    q.BrandID,
                    q.PackUnitID,
                    q.GoodsPriceCondID,
                    q.Sorts,
                    q.CurPage);
        }
        #endregion





    }
}
